package com.nulldev.util.web.HttpServer3.extensions.warLoader;

import java.io.File;
import java.io.FileInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import com.nulldev.util.JVM.JVM;
import com.nulldev.util.data.Variables;
import com.nulldev.util.io.IOUtils;
import com.nulldev.util.io.file.FileUtil;

public class WARLoader {

	public static void loadWar(final File file) throws Exception {
		Variables.requireNonNull(file, "file");
		if (!FileUtil.getFileExtension(file).equalsIgnoreCase("war"))
			throw new UnsupportedOperationException("Cannot load non .war file: " + file);
		final ZipInputStream zf = new ZipInputStream(new FileInputStream(file));
		boolean hasWarConfig = false;
		ZipEntry entry;
		while ((entry = zf.getNextEntry()) != null) {
			JVM.println(entry);
		}
		IOUtils.closeQuietly(zf);
	}

	public static void main(String[] args) {

	}
}
